package android;

import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.content.Intent;
import geofencing.dlrl.com.mygeofencing.GeoFencingActivity;

/**
 * This class echoes a string called from JavaScript.
 */
public class geofencingplugin extends CordovaPlugin {

    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
        if (action.equals("coolMethod")) {
            String message = args.getString(0);
            this.coolMethod(message, callbackContext);
            return true;
        }
        return false;
    }

    public void coolMethod(String message, CallbackContext callbackContext) {

        Intent intent = new Intent(this.cordova.getActivity(), GeoFencingActivity.class);

        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        intent.putExtra("mode","auth");

        intent.setPackage(this.cordova.getActivity().getApplicationContext().getPackageName());

        if (this.cordova != null) {

         this.cordova.startActivityForResult((CordovaPlugin) this, intent, 0);

        }

//        if (message != null && message.length() > 0) {
//            callbackContext.success(message);
//        } else {
//            callbackContext.error("Expected one non-empty string argument.");
//        }
    }
}
